import 'package:flutter/material.dart';

class TodoListPage extends StatefulWidget {
  const TodoListPage({super.key});
  static const String route = '/home';
  @override
  State<TodoListPage> createState() => _TodoListState();
}

class _TodoListState extends State<TodoListPage> with SingleTickerProviderStateMixin {
  final List<Tab> tabs=<Tab>[
    const Tab(icon: Icon(Icons.directions_car)),
    const Tab(icon: Icon(Icons.directions_transit)),
    const Tab(icon: Icon(Icons.directions_bike)),
    const Tab(icon: Icon(Icons.directions_car)),
    const Tab(icon: Icon(Icons.directions_transit)),
    const Tab(icon: Icon(Icons.directions_bike)),
    const Tab(icon: Icon(Icons.directions_car)),
    const Tab(icon: Icon(Icons.directions_transit)),
    const Tab(icon: Icon(Icons.directions_bike)),
    const Tab(icon: Icon(Icons.directions_car)),
    const Tab(icon: Icon(Icons.directions_transit)),
    const Tab(icon: Icon(Icons.directions_bike)),
  ];
  final List<Widget> tabViews=List<Widget>.generate(12, 
    (index) =>ListView.builder(
      itemCount: 12,
      shrinkWrap: true,
      itemBuilder: (context, index){
        return ExpansionTile(
          title: Column(
            children:[
               Text('Item $index',style: const TextStyle(fontSize: 18),),
               Text('Item $index',style: const TextStyle(fontSize: 14,color: Colors.grey),)
            ]
          ),
        );
      },
    )
  );
  late TabController _controller;
  final snackBar = const SnackBar(
    content: Text('加载'),
    backgroundColor: Colors.blue,
  );
  @override
  void initState(){
    super.initState();
    _controller=TabController(length: 12, vsync: this);
  }
  @override
  void dispose(){
    _controller.dispose();
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers:[
            SliverAppBar(
              pinned: true,
              expandedHeight: 100,
              flexibleSpace: const FlexibleSpaceBar(
                title: Text('1',style: TextStyle(color: Colors.blue),),
                // background: Image.network(
                //   'https://example.com/your_image.jpg',
                //   fit: BoxFit.cover,
                // ),
              ),
              bottom: TabBar(
                tabs: tabs,
                controller: _controller,
                isScrollable: true,
              ),
            ),
            SliverFillRemaining(
              child: TabBarView(
                controller: _controller,
                children: tabViews,
              ),
            )
          ]
        ),
        // drawer: Drawer(
        //   child: SingleChildScrollView(
        //     child: Column(children: [
        //       const SizedBox(
        //         height: 100,
        //       ),
        //       Wrap(children: [
        //         TextButton(
        //             onPressed: () {
        //               ScaffoldMessenger.of(context).showSnackBar(snackBar);
        //             },
        //             child: const Text('测试')
        //         ),
        //         TextButton(onPressed: () {}, child: const Text('物资及服务需求单')),
        //       ]),
        //     ]),
        //   ),
        // ),
    );
  }
}
